************* Do-file for: Analysis of ANES/MTurk Merge ****************
************* Date Modified: 09/09/2020  	            ****************
************* Created by: Adam D. Wolsky 	            ****************

clear
cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Analysis/Merge_Descriptives/Data"
use "merge_descriptives.dta"

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Analysis/Merge_Descriptives/"

log using descriptives, replace name("Descriptive Log")

/* download user-written command estout; type "ssc install estout" */

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Tables"

estpost prtest female hisp black asian partisan democrat republican college, by(anes)
matrix prop1=e(P_1)
matrix list prop1

estpost prtest female hisp black asian partisan democrat republican college, by(anes)
matrix prop0=e(P_2)
matrix list prop0

estpost prtest female hisp black asian partisan democrat republican college, by(anes)
estadd matrix prop1
estadd matrix prop0

esttab using diffinprop.rtf, noobs cells("prop1(fmt(4)) prop0(fmt(4)) b(star fmt(4)) se(fmt(4))") ///
star(* 0.1 ** .05 *** 0.01) collabels("Prop(MTurk)" "Prop(ANES)" "Diff." "Std. Error") replace

eststo clear

estpost ttest age, by(anes)
matrix meanf1=e(mu_1)
matrix list meanf1

estpost ttest age, by(anes)
matrix meanf0=e(mu_2)
matrix list meanf0

estpost ttest age, by(anes)
estadd matrix meanf1
estadd matrix meanf0

esttab using diffinmeans.rtf, noobs cells("meanf1(fmt(4)) meanf0(fmt(4)) b(star fmt(4)) se(fmt(4))") ///
star(* 0.1 ** .05 *** 0.01) collabels("Mean(MTurk)" "Mean(ANES)" "Diff." "Std. Error") replace

log close _all
